<template>
  <div class="mod-home">
    <div class="m-modul">
      <el-row :gutter="20">
        <el-col
          :span="6"
          class="u-el-col"
          v-if="isButtonAuth('sys:question:admin')"
        >
          <div class="u-img-box" @click="routerToQuestion()">
            <img class="u-img-bg" src="../../assets/img/class_page.png" alt />
          </div>
          <a @click="routerToQuestion()">题库</a>
        </el-col>
        <el-col :span="6" class="u-el-col">
          <div class="u-img-box" @click="routerToWork()">
            <img class="u-img-bg" src="../../assets/img/class_page.png" alt />
          </div>
          <a @click="routerToWork()">备课</a>
        </el-col>
        <el-col :span="6">
          <div class="grid-content bg-purple"></div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  created() {
    console.log(window.HTTP_TYPE, 'window.HTTP_TYPEwindow.HTTP_TYPE');
  },
  methods: {
    routerToQuestion() {
      let token = this.$cookie.get('token');
      // 跳转题库后台
      console.log(~window.location.host.indexOf('localhost'));
      if (~window.location.host.indexOf('dev')) {
        // 开发环境跳转
        window.open(
          'http://jzjx-dev.hailiangjy.com:8081/question/#/Login?token=' + token
        );
      } else if (~window.location.host.indexOf('test')) {
        // 测试环境跳转
        window.open(
          'http://jzjx-question-test.hailiangjy.com/#/Login?token=' + token
        );
      } else if (~window.location.host.indexOf('pre')) {
        // 预发环境跳转
        window.open(
          'http://jzjx-question-test.hailiangjy.com/#/Login?token=' + token
        );
      } else {
        // 生产环境跳转
        window.open(
          'https://jzjx-resources.hailiangedu.com/#/Login?token=' + token
        );
      }

      // window.open('http://admin.niceol.com:8099')
      this.$router.push({ name: 'home' });
    },
    routerToWork() {
      let token = this.$cookie.get('token');
      // 跳转备课后台
      console.log(~window.location.host.indexOf('localhost'));
      if (~window.location.host.indexOf('dev')) {
        // 开发环境跳转
        window.open('http://jzjx-dev.hailiangjy.com:8081/prepare/#/login');
      } else if (~window.location.host.indexOf('test')) {
        // 测试环境跳转
        window.open('http://jzjx-prepare-test.hailiangjy.com/#/Login');
      } else if (~window.location.host.indexOf('pre')) {
        // 预发环境跳转
        window.open('http://jzjx-prepare-test.hailiangjy.com/#/Login');
      } else {
        // 生产环境跳转
        window.open('https://jzjx-prepare.hailiangedu.com/#/Login');
      }

      // window.open('http://admin.niceol.com:8099')
      this.$router.push({ name: 'home' });
    },
    routerToExcellent() {
      let token = this.$cookie.get('token');
      // 跳转精品课程
      console.log(~window.location.host.indexOf('localhost'));
      if (~window.location.host.indexOf('dev')) {
        // 开发环境跳转
        window.open('http://excellent.admin.dev.hyl-edu.com');
      } else if (~window.location.host.indexOf('test')) {
        // 测试环境跳转
        window.open('http://excellent.admin.test.hyl-edu.com');
      } else if (~window.location.host.indexOf('pre')) {
        // 预发环境跳转
        window.open('http://pre.excellent.admin.edu.otter-innov.net');
      } else {
        // 生产环境跳转
        window.open('http://excellent.admin.test.hyl-edu.com');
      }
      // window.open('http://admin.niceol.com:8099')
      this.$router.push({ name: 'home' });
    },
    routerToLinclass() {
      // 跳转领课后台
      if (window.HTTP_TYPE === 'dev') {
        // 开发环境跳转
        window.open('http://pick-lessons.niceol.com/#/courselist');
      } else if (window.HTTP_TYPE === 'test') {
        // 测试环境跳转
        window.open('http://pick-lessons.niceol.com/#/courselist');
      } else if (window.HTTP_TYPE === 'uat') {
        // 预发环境跳转
        window.open('http://pick-lessons.niceol.com/#/courselist');
      } else {
        // 生产环境跳转
        window.open('http://pick-lessons.niceol.com/#/courselist');
      }
      this.$router.push({ name: 'home' });
    },
  },
};
</script>

<style>
.mod-home {
  line-height: 1.5;
}

.m-modul a {
  font-size: 18px;
}

.m-modul {
  text-align: center;
}

.u-img-bg {
  object-fit: cover;
  width: 100%;
  height: 100%;
  /* min-width: 375px; */
  /* min-height: 223px; */
}

.u-el-col {
  height: 390px;
  padding: 10px;
  border: 2px solid silver;
  margin: 15px;
  border-radius: 4px;
}

.u-el-col:hover {
  cursor: pointer;
  transform: scale(1.03);
  transition: all 0.2s;
  box-shadow: 2px 2px 10px 2px rgba(213, 213, 213, 0.5);
}

.u-img-box {
  height: 300px;
  margin-bottom: 30px;
}
</style>
